package TeacherEvaluation.com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import TeacherEvaluation.com.dao.courseDao;
import TeacherEvaluation.com.entity.Course;

@Service
public class courseService {
	
	@Autowired
	courseDao cDao;
	
	public int insertCou(Course course) {
		int i = cDao.selectCouByname(course.getCourse());
		if (i>0) {
			return 0;
		}else {
			return cDao.insertCou(course);
		}
	};
	
	public List<Course> selectCou(){
		return cDao.selectCou();
	};
	
	public int updateCou(Course course) {
		int i = cDao.selectCouByname(course.getCourse());
		if (i>0) {
			return 0;
		}else {
			return cDao.updateCou(course);
		}
	};
	public int	deleCou(int co_id) {
		int i = cDao.deleCou(co_id);
		if(i==0) {
			return 0;
		}else {
			return i;
		}
	};
	
	public Course selectCouByCoId(int co_id) {
		return cDao.selectCouByCoId(co_id);
	};
}
